//
//  ViewController.m
//  DailyTest
//
//  Created by hjk on 16/6/23.
//  Copyright © 2016年 kobehjk. All rights reserved.
//

#import "ViewController.h"
#import "SingletonManager.h"
#import "RunTimeExample.h"
//#import "QuartzCore.h"

@interface ViewController ()
{
    UIView *view1;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor yellowColor];
//    SingletonManager *tool1 = [SingletonManager shareInstance];
//    SingletonManager *tool2 = [SingletonManager shareInstance];
//    NSLog(@"tool1-----%p",&tool1);
//    NSLog(@"tool2-----%p",&tool2);
    
    //[RunTimeExample creatClassAndMethod];
    
    view1 = [[UIView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH-400)/2, (SCREEN_HEIGHT-400)/2, 400, 400)];
    view1.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view1];
    
    CALayer *bluelayer = [CALayer layer];
    bluelayer.backgroundColor = [UIColor blueColor].CGColor;
    bluelayer.frame = CGRectMake((view1.bounds.size.width-100)/2, (view1.bounds.size.height-100)/2, 100, 100);
    bluelayer.delegate = self;
    bluelayer.contentsScale = [UIScreen mainScreen].scale;
    [view1.layer addSublayer:bluelayer];
    
    [bluelayer display];
//    UIImage *img = [UIImage imageNamed:@"001"];
//    view1.layer.contents = (__bridge id)img.CGImage;
////    view1.contentMode = UIViewContentModeScaleToFill;
////    view1.layer.contentsGravity = kCAGravityCenter;
////    view1.layer.contentsScale = img.scale;
//    view1.layer.contentsCenter = CGRectMake(0.25, 0.25, 0.5, 0.5) ;

    
}

-(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
    CGContextSetLineWidth(ctx, 10.0f);
    CGContextSetStrokeColorWithColor(ctx, [UIColor redColor].CGColor);
    CGContextStrokeEllipseInRect(ctx, layer.bounds);
}

-(void)viewAmimated
{
    
    CGPoint oldOrigin = view1.frame.origin;
    NSLog(@"%f----%f",oldOrigin.x,oldOrigin.y);
    NSLog(@"%f----%f",view1.layer.position.x,view1.layer.position.y);
    view1.layer.anchorPoint = CGPointMake(1, 0.5);
    CGPoint newOrigin = view1.frame.origin;
    NSLog(@"%f----%f",newOrigin.x,newOrigin.y);
    NSLog(@"%f----%f",view1.layer.position.x,view1.layer.position.y);
//    CGPoint transition;
//    transition.x = newOrigin.x - oldOrigin.x;//-100
//    transition.y = oldOrigin.y - oldOrigin.y;//-100
//    
//    view1.center = CGPointMake (view1.center.x - transition.x, view1.center.y - transition.y);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
